package com.quanxi.qxaimain.dao.SDQuery;

import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.mapping.StatementType;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 *  处理流数据的公用接口
 * @Author lyx
 * @create 2022/11/28 17:33
 */

@Component
public interface  SDQueryMapper {
    /**
     * ResultSetType.FORWARD_ONLY 表示游标只向前滚动
     * fetchSize 每次查询數量
     * @ResultTyp 定义返回的对象类型
     *
     * @param sql  SQL語句
     * @param handler  返回处理数据对象
     */

    @Select("${sql}")
    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000,statementType = StatementType.PREPARED)
    @ResultType(Map.class)
    void streamDataDynamicHandle(@Param("sql") String sql, ResultHandler<Map> handler);

//
//    @Select("${sql}")
//    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000)
//    @ResultType(User.class)
//    void dynamicSelectLargeData1(@Param("sql") String sql, ResultHandler<User> handler);
//
//    @Select("select * from user t ${ew.customSqlSegment}")
//    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000,statementType = StatementType.PREPARED)
//    @ResultType(User.class)
//    void getOrgWithBigData(@Param(Constants.WRAPPER) QueryWrapper<User> wrapper, ResultHandler<User> handler);


}